<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
    /**
     * @author 谭湘元
     * @since 2009/04/23
     */
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030" />
<title>聋校备课与语言学习及矫治系统</title>
<fmt:setBundle basename="PathResource" scope="session" />
<link href="<%=request.getContextPath()%>/<fmt:message key='StylePath' />style2.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript">
	var sound_text="<c:out value="${__rescue_study_resouce_container_prefix_.currentbook.scoreText}" />";//语音文本值，评测所需参数，位于教材中
	var ocx_work_dev="d:\\env";
	var wav_name = "record.wav";
	var appletPosition = "left";
	var currentApplet;

	var contentSourceSrc;
	var contentWindow;
	var topWindow;
	var bottomWindow;
	var rightWindow;
	
	function startEvaluation(){
		var studentID = rightWindow.getStudentID();
		if(studentID==""){
			alert("请先选择学生！");
			return "";
		}
		currentApplet.clearOldWaves();//清空applet中原有的波形数据
		//t_ocx.SetParamer("interval", "20");

		ocx_work_dev = t_ocx.SetParamer("wavefile0", "wave_0.pcm"); // 设置保存原始波形文件名（pcm 格式）
		if(ocx_work_dev==""){
			alert("页面控件错误！");
		}
		t_ocx.SetParamer("wavefile1", "wave_1.data"); // 设置保存包络波形文件名
		t_ocx.SetParamer("wavefile2", "wave_2.data"); // 设置保存音强波形文件名
		t_ocx.SetParamer("wavefile3", "wave_3.data"); // 设置保存基频波形文件名
		t_ocx.SetParamer("wavefile4", "wave_4.data"); // 设置保存有无声波形文件名
		//t_ocx.SetParamer("recordfile", wav_name); // 设置保存录音文件文件名
		t_ocx.SetEvalLevel(bottomWindow.evaluateLevel);
		t_ocx.SetParamer ("samplerate ", "20");
		t_ocx.SetParamer ("datatype", "10");
		t_ocx.SetDeviceVolume(80,true);
		/* 设置以上参数表示要保存相应波形，否则不保存 */
		t_ocx.InitEngine(); // 初始化引擎
		
		t_ocx.DoEvaluation(sound_text, "");
	}
	//显示评分结果回调函数	
	function viewEvaluationResult(xml,applet){
		bottomWindow.openEvaluationResultDialog(xml);
		
	}
	//获取开始按钮
	function getStartButton(){
		return document.getElementById("startButton");
	}
	//改变评分文本
	function changeRecordText(text){
		sound_text = text;
	}

	var url = "<%=request.getContextPath()%>/teachBook.do?method=dowloadTeachBookFile&bookID=<c:out value="${__rescue_study_resouce_container_prefix_.currentbook.bookId}" />";
	
	var chineseFile = url+"&fileType=chineseFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.jpgSubffix }" />";
	var pinyinFile = url+"&fileType=pinyinFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.jpgSubffix }" />";
	var mouthFile = url+"&fileType=mouthFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.aviSubffix }" />";
	var pictureFile = url+"&fileType=pictureFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.jpgSubffix }" />";
	var zimuFile = url+"&fileType=zimuFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.jpgSubffix }" />";
	var signFile = url+"&fileType=signFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.aviSubffix }" />";
	var soundFile = url+"&fileType=soundFile&fileSubffix=<c:out value="${__rescue_study_resouce_container_prefix_.builder.wavSubffix }" />";

	
	
	function topMenuChanged(index){
		if(index==1){
			contentSourceSrc = getImgSource(chineseFile);
		}else if(index==2){
			contentSourceSrc = getImgSource(pinyinFile);
		}else if(index==3){
			contentSourceSrc = getVadioSource(mouthFile);
		}else if(index==4){
			contentSourceSrc = getImgSource(pictureFile);
		}else if(index==5){
			contentSourceSrc = getImgSource(zimuFile);
		}else if(index==6){
			contentSourceSrc = getVadioSource(signFile);
		}else if(index==7){
			contentSourceSrc = getVadioSource(soundFile);
		}

		//centerLoadCallback=function(){
			contentWindow.freshContent(contentSourceSrc);//改变中间显示区域的内容为菜单对应内容
		//};
		//contentWindow.location = contentWindow.location;//刷新中间内容区域 释放页面内存资源
		appletPosition = "left";
		currentApplet=soundWaveApplet;
	}
	function appletDoubleClicked(){//applet双击事件
		//centerLoadCallback=function(){
			contentWindow.freshContent(getAppletSouce());//为内容区域添加applet
		//};
		//contentWindow.location = contentWindow.location;//刷新中间内容区域 释放页面内存资源

		appletPosition = "center";
		topWindow.enableAllImgs();//改变top工具栏的选中状态（未选中）
		currentApplet = contentWindow.soundWaveApplet;
	}
	var centerLoadCallback = function(){//center区域加载完毕后的回调方法
		//alert("第一次");
	};
	function jumpToTeachBook(index){
		if(index<0){ 
			alert("已经是第一篇教材了."); 
			return;
		}
		var totalCount = <c:out value="${__rescue_study_resouce_container_prefix_.totalBookCount}" />;
		if(index>=totalCount) {
			alert("已经是最后一篇教材了."); 
			return;
		}
		topWindow.enableAllImgs();//改变top工具栏的选中状态（未选中）
		contentWindow.freshContent("");//清空内容区域
		frameSetSubmit("<%=request.getContextPath()%>/evaluation.do?method=loadLeftPanel&currentBookIndex="+index);
	}
	function frameSetSubmit(url){//以刷新页面的方式提交数据 （只提交左侧页面）
		document.forms[0].action = url;
		document.forms[0].submit();
	}
	function getImgSource(src){
		return "<img src=\""+src+"\" width=\"100%\" height=\"449\" />";
	}
	function getVadioSource(src){
		return "<object id=\"audioPlayer\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" width=\"100%\" height=\""+449+"\" id=\"MediaPlayer1\"><param name=\"FileName\" value=\""+src+"\" /><param name=\"AutoStart\" value=\"1\"/><param name=\"AutoSize\" value=\"1\"/></object>";
	}
	function getAppletSouce(){//为中间内容区域构造applet显示波形
		var result = "<applet id=\"soundWaveApplet\" name=\"soundWaveApplet\" archive=\"<%=request.getContextPath()%>/<fmt:message key='common' />sound-wave.jar\" code=\"SoundWave.class\" width=392 height=449>";
		result += "<param name=width value=\"392\" />";
		result += "<param name=height value=\"449\" />";
		result += "<param name=islarge value=\"true\" />";
		result += "</applet>";
		return result;
	}
	
	function getEvaluateParamerData(type){//获取控件评价后的参数信息（如：包络、音强...）
		return t_ocx.GetBaoLuoData(type);
	}
	var interval;//间隔变量
	function replayVoice(button,selfButton){
		if(bottomWindow.isAutoReplay){
			interval = window.setInterval(function(){
				MediaPlayer1.FileName=ocx_work_dev + "\\" + wav_name;
				MediaPlayer1.Play();
				},bottomWindow.waitMilliSeconds*1000);
		}else{
			MediaPlayer1.FileName=ocx_work_dev + "\\" + wav_name;
			MediaPlayer1.Play();
		}
		button.style.display = "block";
		selfButton.style.display = "none";
	}
	function dealInterval(button,selfButton){
		button.style.display = "block";
		selfButton.style.display = "none";
		if(interval){
			window.clearInterval(interval);
			interval = "";
		}
		MediaPlayer1.Stop();
	}
	function displayApplet(text){
		if(soundWaveApplet){
			soundWaveApplet.style.display = text;
		}
		if(contentWindow.soundWaveApplet){
			contentWindow.soundWaveApplet.style.display = text;
		}
		if(contentWindow.audioPlayer){
			contentWindow.audioPlayer.style.display = text;
		}
	}
	window.onload = function(){
		contentWindow = self.parent.frames["center"];
		topWindow = self.parent.frames["topFrame"];
		bottomWindow = self.parent.frames["bottomFrame"];
		rightWindow = self.parent.frames["rightFrame"];
		currentApplet = soundWaveApplet
	}
	
</script>
<script for="t_ocx" event=SpeechData(data) type="text/javascript">
	//alert(data);
	currentApplet.addData(data);
</script>
<SCRIPT FOR=t_ocx EVENT=ResultReady(resutl) type="text/javascript">
	currentApplet.showLinesInArea();
	viewEvaluationResult(resutl,currentApplet);	
</SCRIPT>
</head>
<body  class="left_style" bgcolor="#ccea68">
<form id="form1" name="form1" method="post" action="">
  <table width="203" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="700" align="right" valign="top" background="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/left_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="120">&nbsp;</td>
          </tr>
          <tr>
            <td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="center"><table width="201" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="170" align="center" valign="middle" background="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/left_01.gif"><table width="182" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td height="155">
								<applet id="soundWaveApplet" name="soundWaveApplet" archive="<%=request.getContextPath()%>/<fmt:message key='common' />sound-wave.jar" code="SoundWave.class" width=182 height=155>
									<param name=width value="182" />
									<param name=height value="155" />
								</applet>
							</td>
                          </tr>
                        </table></td>
                      </tr>
                  </table></td>
                </tr>
                <tr>
                  <td align="center"><table width="80%" border="0" cellspacing="10" cellpadding="0">
                      <tr>
                        <td align="center" valign="middle">
							<a href="#" onfocus="this.blur()">
								<img id="startButton" onclick="startEvaluation();" src="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/kaishi.gif" width="53" height="22" border="0" /></a></td>
                        <td align="center" valign="middle">
							<a href="#" onfocus="this.blur()">
								<img id="replayButton" onclick="javascript:replayVoice(stopButton,this);" src="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/huifang.gif" width="53" height="22" border="0" />
								<img id="stopButton" onclick="javascript:dealInterval(replayButton,this);" src="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />stop.gif" style="display:none" width="53" height="22" border="0" /></a></td>
                      </tr>
                      <tr>
                        <td align="center" valign="middle">
							<a href="javascript:jumpToTeachBook('<c:out value="${__rescue_study_resouce_container_prefix_.currentBookIndex-1}" />');" onfocus="this.blur()">
								<img src="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/shangyipian.gif" width="53" height="22" border="0" /></a></td>
                        <td align="center" valign="middle">
							<a href="javascript:jumpToTeachBook('<c:out value="${__rescue_study_resouce_container_prefix_.currentBookIndex+1}" />');" onfocus="this.blur()">
								<img src="<%=request.getContextPath()%>/<fmt:message key='CommonImagePath' />jz_img/jzxx/xiayipian.gif" width="53" height="22" border="0" /></a></td>
                      </tr>
                  </table></td>
                </tr>
                <tr>
                  <td align="center"></td>
                </tr>
            </table></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>
<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="0" height="0">
	<param name="AutoStart" value="1"/>
</object>
<object id="t_ocx" width=0 height=0 classid="CLSID:BAAA7FE8-09E2-4011-9333-C6DFC8D9749D">
    <param name="_Version" value="65536"/>
    <param name="_ExtentX" value="2646"/>
    <param name="_ExtentY" value="1323"/>
    <param name="_StockProps" value="0"/>
</object>
</body>
</html>
